//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package servlet;

import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import model.Order;
import model.User;
import service.OrderService;

@WebServlet(
    name = "order_list",
    urlPatterns = {"/order_list"}
)
public class OrderListServlet extends HttpServlet {
    private OrderService oService = new OrderService();

    public OrderListServlet() {
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        User u = (User)request.getSession().getAttribute("user");
        if (u == null) {
            response.sendRedirect("/index");
        } else {
            List<Order> list = this.oService.selectAll(u.getId());
            request.setAttribute("orderList", list);
            request.getRequestDispatcher("/order_list.jsp").forward(request, response);
        }
    }
}
